# coding:utf-8
# __user__ = hiicy redldw
# __time__ = 2019/8/30
# __file__ = control_flow
# __desc__ =

import tensorflow as tf

var = tf.Variable(3)
top = var * 2
# with tf.control_dependencies([top]):
#     bot = var.assign_add(2)
bot = var.assign_add(2)
out = top + bot
t = tf.summary.scalar('out',out)

with tf.Session() as sess:
    sess.run(tf.global_variables_initializer())
    fs = tf.summary.FileWriter(r"F:\tmp\events",graph=sess.graph)
    fmer = tf.summary.merge_all()
    to,ou, fm = sess.run([top,out,fmer])
    print('top:',to)
    print('out:',ou)
    fs.add_summary(fm)

# tf.while_loop 可以这样理解
# loop = []
# while cond(loop):
#     loop = body(loop)
tf.while_loop